cmake_minimum_required(VERSION 3.11)

include(FetchContent)
# FetchContent_MakeAvailable was not added until CMake 3.14
if(${CMAKE_VERSION} VERSION_LESS 3.14)
  include(add_FetchContent_MakeAvailable.cmake)
endif()

message(STATUS "--- Add dependence glm")

set(glm_FILE
    ""
    CACHE STRING "glm file")
set(glm_GIT_URL
    https://gitee.com/snow-github-mirrors/glm.git
    CACHE STRING "glm git url")
set(glm_GIT_TAG
    0.9.9.8
    CACHE STRING "glm git tag")

set(WITH_APPS OFF)

if(glm_FILE)
  message(STATUS "--- Use File")
  message(STATUS "\t --- File: ${glm_FILE}")
  FetchContent_Declare(glm URL ${glm_FILE} SOURCE_DIR
                                   ${PROJECT_ROOT}/3rdparty/glm)
else()
  message(STATUS "--- Use Git")
  message(STATUS "\t --- Repository: ${glm_GIT_URL}")
  message(STATUS "\t --- Version: ${glm_GIT_TAG}")
  FetchContent_Declare(
    glm
    GIT_REPOSITORY ${glm_GIT_URL}
    GIT_TAG ${glm_GIT_TAG}
    SOURCE_DIR ${PROJECT_ROOT}/3rdparty/glm
    GIT_PROGRESS TRUE
    USES_TERMINAL_DOWNLOAD TRUE)
endif()

FetchContent_MakeAvailable(glm)

message(STATUS "--- Add dependence glm finished.")
